/*
 * Copyright (c) 2018-2023 北京华恒盛世科技有限公司
 * QUICKPOOL is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *     http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
*/

#ifndef SUBCMD_HEADER
#define SUBCMD_HEADER

#include <getopt.h>

#include "xdrbase.h"
#include "common.h"
#include "json.h"
#include "quickpool.h"
#include "api.h"
#include "subcmd.admin.h"

#define QUEUE_HIST 1
#define HOST_HIST  2
#define JS_HIST    3
#define SYS_HIST   4

struct histReq {
    short request_code;
    unsigned int num_name;
    char **names;
    time_t log_time[2];
    char *search_filename;
    bool_t found;
};

extern int set_submit_request(int, char **, enum submitType, struct request *);
extern json *submitrequest_2json(struct QuickPoolJobInfo *);

extern void admin_usage(int);

extern const char *get_status(struct QuickPoolJobInfo *);
extern const char *get_post_status(struct QuickPoolJobInfo *);
extern unsigned int get_argument_names(int, char **, int, char ***, int *, const char *);
extern int get_jobids_fromargv(int, char **, JOBID_T **);
extern int get_one_jobid(char *, JOBID_T *);

extern int cmd_submit_job(int, char**);
extern int cmd_list_jobs(int, char**);
extern int cmd_job_records(int, char**);
extern int cmd_modify_job(int, char**);
extern int cmd_switch_job(int, char**);
extern int cmd_signal_job(int, char **);
extern int cmd_run_job(int, char**);
extern int cmd_move_job(int, char **);
extern int cmd_migrate_job(int, char**);
extern int cmd_requeue_job(int, char**);
extern int cmd_read_message(int, char**);
extern int cmd_peek_job(int, char**);
extern int cmd_post_message(int, char**);
extern int cmd_list_jobgroups(int, char**);
extern int cmd_add_jobgroup(int, char**);
extern int cmd_delete_jobgroup(int, char**);
extern int cmd_modify_jobgroup(int, char**);
extern int cmd_job_dependency(int, char**);
extern int cmd_admin_control(int, char *[], admin_control_t);
extern int cmd_list_queues(int, char**);
extern int cmd_show_settings(int, char**);
extern int cmd_list_nodes(int, char**);
extern int cmd_node_info(int, char**);
extern int cmd_list_groups(int, char**);
extern int cmd_list_users(int, char**);
extern int cmd_list_clusters(int, char**);
extern int cmd_list_resources(int, char**);
extern int cmd_node_load(int, char**);
extern int cmd_remove_node(int, char**);
extern int cmd_add_node(int, char**);
extern int cmd_cluster_info(int, char**);
extern int cmd_resource_info(int, char **);
extern int startup(int, char **);
extern int cmd_file_copy(int, char**);
char *get_queuestatus(struct QuickPoolQueueInfo *, char stat[]);
char *get_hoststatus(struct QuickPoolHostInfo *, char stat[]);
#endif
